<!DOCTYPE html>
<#assign contextPath=request.contextPath>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <base href="${contextPath}/" />
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="css/bootstrap/bootstrap.min.css" rel="stylesheet">
    <link href="css/font-awesome.min.css" rel="stylesheet">
    <link href="css/login.css" rel="stylesheet">
  
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>
</head>

<body class="signin">
    <div class="signinpanel">
        <div class="row">
            <div class="col-sm-12">
                <form method="post" action="${contextPath}/account/login" id="documentForm">
                    <h4 class="no-margins font_white">登录</h4>
                    <p class="m-t-md font_white">登录使用健康保健管理系统</p>
                    <input type="text" name="account" autocomplete="off"  class="form-control uname" placeholder="编号/手机号码" required minlength=4  />
                    <input type="password" name="pwd" autocomplete="off"  class="pwd form-control pword m-b" placeholder="密码" required minlength=6 />
                    <br/>
                    <a href=""></a>
                    <a class="btn btn-success btn-block font_white" id="submit" >登录</a>
                </form>
            </div>
        </div>
        <div class="signup-footer">
            <div class="pull-left">
                &copy; 健康保健
            </div>
        </div>
    </div>
    <!-- 全局js -->
    <script src="js/jQuery/jquery.min.js"></script>
    <script src="js/bootstrap/bootstrap.min.js"></script>
    <script src="js/layer/layer.js"></script>
    <script src="js/common/md5.js"></script>
    <script src="js/validate/jquery.validate.min.js"></script>
    <script>
    	$(function(){
		   $("#submit").click(function(){
				if (validateForm()) {
			        $.post("${contextPath}/account/login", { "account": $("[name=account]").val(), "pwd": $("[name=pwd]").val().MD5() },showResponse);
					return false;
				}
			})
    	})
    	
    	//ajax 返回
		function showResponse(responseText, statusText) {
			var code = responseText.code;
			var msg = responseText.msg;
			if (code == "1") {
				location.href="${contextPath}/index.html";
			} else {
				layer.tips(msg, '.pwd',{tips: [3, 'red']});
			}
		}	
		
		//表单验证
		function validateForm(){
		   return $("#documentForm").validate({
			    messages: {
			    	account: {
			    		required:"用户名不允许为空",
			    		minlength:"用户名至少为6位"
			    	},
			    	pwd: {
			    		required:"密码不允许为空",
			    		minlength:"密码至少为6位"
			    	},
			    }
			}).form();
		}
    </script>
</body>
</html>
